import router from './router'
import { getToken } from './utils/cookieUtil'

const whiteList = ['/login']

router.beforeEach((to, _from, next) => {
    if (getToken()) {
        if (to.path === '/login') next('/profile')
        else next()
    } else {
        if (whiteList.indexOf(to.path) !== -1) {
            next()
        } else {
            next('/login')
        }
    }
})